package com.yiyun.blog.controller;

import com.sun.mail.imap.protocol.ID;
import com.yiyun.blog.service.CategoryService;
import com.yiyun.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Bao
 * @create 2022-05-09-20:54
 */
@RestController
@RequestMapping("categorys")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public Result categories(){
        // 查找全部分类
        return categoryService.findAllCategory();
    }

    @GetMapping("detail")
    public Result categoriesDetail(){
        // 查找分类详情
        return categoryService.findAllCategoryDetail();
    }

    @GetMapping("detail/{id}")
    public Result categoryDetailById(@PathVariable("id") Long categoryId){
        // 查找该分类下的文章
        return categoryService.categoryDetailById(categoryId);
    }
}
